package com.act.web;

import javax.annotation.Resource;

import org.apache.log4j.Logger;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.act.domain.AuditProce;
import com.act.dto.PagerDTO;
import com.act.dto.Response;
import com.act.service.api.IAuditProceService;
import com.act.util.LoggerUtil;

/**
* @Desccription:类说明
* @Author: 刘承军
* @E-mail:923050345@qq.com
* @Date:2017年11月14日 上午11:35:48  
*/

@RestController
@RequestMapping("/auditProce")
public class AuditProceController {

	@Resource
	private IAuditProceService auditProceService;	
	
	private final Logger LOGGER = Logger.getLogger(AuditProceController.class);	
	
    @RequestMapping(value = "/add",method = RequestMethod.POST)
    @ResponseBody
    public Response add(AuditProce auditProce) {
    	 try {
    		 auditProceService.add(auditProce);
             return Response.success();
         } catch (Exception e) {
        	 LoggerUtil.error(LOGGER, e);
             return Response.fail();
         }
    }
    
    @RequestMapping(value = "/update",method = RequestMethod.POST)
    @ResponseBody
    public Response update(AuditProce auditProce) {
    	 try {
    		 auditProceService.update(auditProce);
             return Response.success();
         } catch (Exception e) {
        	 LoggerUtil.error(LOGGER, e);
             return Response.fail();
         }
    }
    
    @RequestMapping(value = "/delete/{id}",method = RequestMethod.GET)
    @ResponseBody
    public Response delete(@PathVariable int id) {
    	 try {
    		 auditProceService.delete(id);
             return Response.success();
         } catch (Exception e) {
        	 LoggerUtil.error(LOGGER, e);
             return Response.fail();
         }
    }
    
    @RequestMapping(value = "/get/{id}",method = RequestMethod.GET)
    @ResponseBody
    public Response getById(@PathVariable int id) {
    	 try {
    		 auditProceService.getById(id);
             return Response.success();
         } catch (Exception e) {
        	 LoggerUtil.error(LOGGER, e);
             return Response.fail();
         }
    }
    
    @RequestMapping(value = "/get",method = RequestMethod.POST)
    @ResponseBody
    public Response getAll(@RequestBody PagerDTO pagerDTO) {
    	 try {
    		 auditProceService.getAll(pagerDTO);
             return Response.success();
         } catch (Exception e) {
        	 LoggerUtil.error(LOGGER, e);
             return Response.fail();
         }
    }
}
